package com.guijq.codesegment.exception;

import lombok.AllArgsConstructor;

@AllArgsConstructor
public enum ErrorType {
    SUCCESS("成功", 200),

    EERROR_PARM_INVAILD("错误参数", 1),
    EERROR_REQUEST_FAILD("请求错误", 2),

    ERROR_SALEORDER_STATUS("销售订单状态错误", 3),

    ERROR_CODE_INVAILD("生产编码错误", 4),
    ERROR_DB("数据库错误", 5),

    ERROR_QCREPORT_RESULT("质检单结果不符合预期", 1010),


    ERROR("失败", 500),
    SALE_ORDER_UNKNOW("未知", 600);


    private String name;
    private Integer index;

    // 普通方法
    public static String getName(int index) {
        for (ErrorType c : ErrorType.values()) {
            if (c.getIndex() == index) {
                return c.name;
            }
        }
        return SALE_ORDER_UNKNOW.name;
    }

    // get set 方法
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }
}
